/* 

	Class: MooStripes
	Add stripes to the table passed in parameters

	Parameters:
	idOfTheTable - Target table.
	oddClass - Class to apply for odd lines (optional).
	evenClass - Class to apply for even lines (optional).
	
	
	Example:
	In the <head> of the html file
	(code)
		<link media="screen" rel="stylesheet" href="css/moostripes.css" type="text/css"/>
		<script src="js/mootools.js" type="text/javascript"></script>
		<script src="js/mooStripes.js" type="text/javascript"></script>

		<script type="text/javascript">
		window.addEvent("domready", function() {
			new mooStripes('idOfTheTable', {oddClass:'odd', evenClass:'even'});
		});
		</script>
	(end code)
	
	Require:
	(code)
		Core
		
	    * Core.js
		
		Class
		
		    * Class.js
		    * Class.Extras.js
		
		Native
		
		    * Array.js
		    * String.js
		    * Function.js
		    * Number.js
		    * Element.js
		
		Element
		
		    * Element.Filters.js
		    * Element.Selectors.js	
	(end code)

	About:
		Moostripes.js v.1.0 for mootools v1.1 05 / 2007
		
		by Floor SA (http://www.floor.ch) MIT-style license
		
		created by David Mignot and Luca Pillonel, last modified by Luca Pillonel 30.05.12
*/

var MooStripes = new Class({
	
	options: {
		oddClass			: 'odd',
		ovenClass			: 'even'
	},
	
	/**
	Constructor: initialize
		constructor
		Set the options and start the ajaxRequest
	*/
	
	initialize: function(container, options) {
		this.setOptions(options);
		this.applyStripes(container);
	},

	/*
	Method: applyStripes
		internal method

	Parameters:
		co 	- ID of the result container
	*/
	
	applyStripes: function(co){
		// With next version of mootools ( > 1.11), something like this will be much faster
		//$$(co  > 'tr:odd').addClass(this.options.ovenClass);
		
		
		// Apply stripes
		$ES('tr', $(co)).each(function(el, n){
			if (n % 2 == 0){
				el.addClass(this.options.ovenClass); 
			} else {
				el.addClass(this.options.oddClass); 
			}
		}, this);
	}
});

mooStripes.implement(new Options);// Implements setOptions(defaults, options)